import './index_PC.scss';
import React, { useEffect, useState, useRef } from "react";
import { user_new_wallet } from '@/utils/mixin.ts'
import { Button, Input, message } from 'antd';
import { ArrowLeftOutlined } from '@ant-design/icons';
import { useNavigate } from 'react-router-dom';

const NewWallet = () => {
    const [walletValue, setWalletValue] = useState([]);
    const navigate = useNavigate();

    const saveWallet = () => {
        user_new_wallet({
            name: walletValue,
            email: localStorage.getItem('email')

        }).then(res => {
            if (res) {
                message.success('添加成功');
                navigate('/dashboard/wallets');
            } else {
                message.error(res.msg);
            }
        });
    }
    return (
        <div className="newWallet">
            <div className="header">
                <Button type="text" onClick={() => window.history.go(-1)} icon={<ArrowLeftOutlined style={{ fontSize: '26px' }} />}></Button>
            </div>
            <div className="content">
                <span>NewWallet</span>
                <Input placeholder='NewWallet' onChange={(e) => { setWalletValue(e.target.value) }}/>
                <Button type="primary" className="save" onClick={() => saveWallet()}>save</Button>
            </div>
        </div>
    )

}

export default NewWallet;